home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h> /* found in MWC p. 406 */
- #define BUFSIZE (20*512)
- char buf[BUFSIZE];
-
- main(argc,argv) int argc; char *argv[];
- {
- register int ifd,ofd;
- register unsigned int n;
- if (argc != 3) fatal("Usage:copy source destination");
- if ((ifd = open(argv[1],0)) == -1) fatal("Cannot open input file");
- if ((ofd = creat(argv[2], 1)) == -1) fatal("Cannot open output file");
- while ((n = read(ifd, buf, BUFSIZE)) != 0) {
- if (n == -1) fatal(" Read Error ");
- if (write(ofd, buf,n) != n) fatal(" Write Error"); }
- if(close(ifd) == -1 || close(ofd) == -1) fatal(" Cannot Close ");
- exit(0);
- }
- fatal(s) char *s;
- {
- fprintf(stderr, "copy: %s\n",s);
- exit(1);
- }
-